package org.xin.security.pojo.form;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.annotations.ApiModel;
import lombok.*;
import lombok.experimental.SuperBuilder;
import org.hibernate.validator.constraints.Length;
import org.xin.framework.base.pojo.form.IBaseForm;
import org.xin.security.common.UserConstants;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import java.io.Serializable;

/**
 * @author ：xin
 * @date ：Created in 17:28
 * @description：
 * @modified By：$
 * @version: $
 */
@Getter
@Setter
/*忽略未知参数*/
@JsonIgnoreProperties(ignoreUnknown = true)
@ApiModel(description = "UserRegisterForm")
public class UserRegisterForm extends IBaseForm implements Serializable {
    private static final long serialVersionUID = 1L;

    @NotBlank(message = "用户名不能为空")
    @Pattern(regexp = "^[\\u4E00-\\u9FA5A-Za-z0-9_]+$", message = "用户名格式应包含中文、英文、数字、下划线")
    @Length(max = UserConstants.USERNAME_MAX_LENGTH, min = UserConstants.USERNAME_MIN_LENGTH, message = "用户名长度应在2-16个字符之间")
    private String username;

    @NotBlank(message = "邮箱不能为空")
    @Email(message = "邮箱格式有误")
    private String email;

    @NotBlank(message = "密码不能为空")
    @Length(max = UserConstants.PASSWORD_MAX_LENGTH, min = UserConstants.PASSWORD_MIN_LENGTH, message = "密码长度应在5-16个字符之间")
    private String password;

    @NotBlank(message = "确认密码不能为空")
    private String password2;

    @NotBlank(message = "验证码不能为空")
    private String code;

    @NotBlank(message = "验证键不能为空")
    private String uuid;
}
